package ds.dsr.global;

import ds.dsr.enums.RetTipEnum;
import ds.dsr.model.RetJson;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author sunchong
 * @date 2018/4/25
 */
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public RetJson catchException(Exception exception){
        RetJson retJson = new RetJson();
        retJson.setCode(RetTipEnum.SYSTEM_ERROR.getCode());
        retJson.setMsg(RetTipEnum.SYSTEM_ERROR.getMsg());
        return retJson;
    }
}
